package cn.damong.weixin.mp;

import java.io.Serializable;

/**
 * 微信网页授权流程用户同意授权后微信服务器返回一个code, 通过code可以换取access_token, 再通过access_token获取用户的基本信息
 * 
 * @author CodingPanda
 * @2019年5月8日 下午10:10:18
 *
 */
public class WeixinAccessToken implements Serializable {
    private static final long serialVersionUID = 8414620288034945381L;

    /**
     * 网页授权接口调用凭证
     */
    private String accessToken;

    /**
     * access_token接口调用凭证超时时间
     */
    private Integer expiresIn;

    /**
     * accessToken有效期只有2个小时，过期后一个月内可以通过refreshToken去刷新accessToken
     */
    private String refreshToken;

    /**
     * 用户唯一标识
     */
    private String openid;

    /**
     * 用户授权的作用域
     */
    private String scope;
    
    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public Integer getExpiresIn() {
        return expiresIn;
    }

    public void setExpiresIn(Integer expiresIn) {
        this.expiresIn = expiresIn;
    }

    public String getRefreshToken() {
        return refreshToken;
    }

    public void setRefreshToken(String refreshToken) {
        this.refreshToken = refreshToken;
    }

    public String getOpenid() {
        return openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    public String getScope() {
        return scope;
    }

    public void setScope(String scope) {
        this.scope = scope;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((accessToken == null) ? 0 : accessToken.hashCode());
        result = prime * result + ((expiresIn == null) ? 0 : expiresIn.hashCode());
        result = prime * result + ((openid == null) ? 0 : openid.hashCode());
        result = prime * result + ((refreshToken == null) ? 0 : refreshToken.hashCode());
        result = prime * result + ((scope == null) ? 0 : scope.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        WeixinAccessToken other = (WeixinAccessToken) obj;
        if (accessToken == null) {
            if (other.accessToken != null) {
                return false;
            }
        } else if (!accessToken.equals(other.accessToken)) {
            return false;
        }
        if (expiresIn == null) {
            if (other.expiresIn != null) {
                return false;
            }
        } else if (!expiresIn.equals(other.expiresIn)) {
            return false;
        }
        if (openid == null) {
            if (other.openid != null) {
                return false;
            }
        } else if (!openid.equals(other.openid)) {
            return false;
        }
        if (refreshToken == null) {
            if (other.refreshToken != null) {
                return false;
            }
        } else if (!refreshToken.equals(other.refreshToken)) {
            return false;
        }
        if (scope == null) {
            if (other.scope != null) {
                return false;
            }
        } else if (!scope.equals(other.scope)) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "WeixinAccessToken [accessToken=" + accessToken + ", expiresIn=" + expiresIn + ", refreshToken="
                + refreshToken + ", openid=" + openid + ", scope=" + scope + "]";
    }

}
